//
//  ZYNCollectionViewCellForRecommendSong.m
//  VideoPic
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZYNCollectionViewCellForRecommendSong.h"
#import "ZYNModelForHotSongs.h"
#import <YYWebImage.h>
#import <UIImageView+WebCache.h>
#define WIDHT self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height

@interface ZYNCollectionViewCellForRecommendSong()
@property (nonatomic, strong) UIImageView *imageForSongPic;
@property (nonatomic, strong) UILabel *labelForTitle;
@property (nonatomic, strong) UILabel *labelForListenCount;
@property (nonatomic, strong) UIImageView *imageForTing;

@end
@implementation ZYNCollectionViewCellForRecommendSong

#pragma mark - init
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

#pragma mark - createSubViews
- (void)createSubViews {
    self.imageForSongPic = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageForSongPic];
    
    self.labelForTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForTitle];
    
    self.imageForTing = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageForTing];
    
    self.labelForListenCount = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForListenCount];
    
}
#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageForSongPic.backgroundColor = [UIColor lightGrayColor];
    
    self.imageForSongPic.frame = self.contentView.frame;
    self.imageForTing.frame = CGRectMake(SCREEN_WIDTH / 2, 5, SCREEN_WIDTH / 6, SCREEN_WIDTH / 6);
    self.imageForTing.image = [UIImage imageNamed:@"Ting"];
    
    self.labelForListenCount.frame = CGRectMake(SCREEN_WIDTH / 4 * 3 - 5, 0, SCREEN_WIDTH / 4 + 5, SCREEN_WIDTH / 4);
    self.labelForTitle.frame = CGRectMake(0, SCREEN_WIDTH, SCREEN_WIDTH, SCREEN_WIDTH / 3);
    self.imageForSongPic.frame = CGRectMake(0, 0, WIDHT, HEIGHT - 40);
    self.imageForTing.frame = CGRectMake(WIDHT / 2, 5, WIDHT / 6, WIDHT / 6);
    self.imageForTing.image = [UIImage imageNamed:@"Ting"];
    
    self.labelForListenCount.frame = CGRectMake(WIDHT / 4 * 3 - 5, 0, WIDHT / 4 + 5, WIDHT / 4);
    self.labelForTitle.frame = CGRectMake(0, HEIGHT - 30, WIDHT, 30);

}
#pragma mark - deliverModel
- (void)passModel:(ZYNModelForHotSongs *)model {
    [self.imageForSongPic  sd_setImageWithURL:[NSURL URLWithString:model.picUrl] placeholderImage:[UIImage imageNamed:@"zw"]];
    self.labelForTitle.text = model.name;
    self.labelForTitle.font = [UIFont systemFontOfSize:14];
    self.labelForTitle.numberOfLines = 0;
    
    CGFloat count = model.listenCount;
    self.labelForListenCount.text = [NSString stringWithFormat:@"%.f万", count / 10000];
    self.labelForListenCount.font = [UIFont systemFontOfSize:12];
    self.labelForListenCount.textColor = [UIColor whiteColor];
    
}

@end
